import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

import java.io.IOException;

public class CreateFile {
    public static void main(String[] args) throws IOException {
        //1.创建词汇表Configuration类型的对象
        Configuration conf =  new Configuration();
        conf.set("fs.defaultFS","hdfs://20210322045-master:9000");

        String temp = args[0];
        FileSystem fs = FileSystem.get(conf);
        FSDataOutputStream out = fs.create(new Path("/tmp/test.txt"));

        out.writeUTF(temp);
        System.out.println("文件写入成功");
        out.close();
        fs.close();

    }
}
